<%@page import="com.person.vo.Article"%>
<%@page import="com.person.daoImpl.AdminDaoImpl"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	request.setCharacterEncoding("UTF-8");
	AdminDaoImpl adi = new AdminDaoImpl();
	int id = Integer.parseInt(request.getParameter("id"));
	Article arti = adi.getArticleById(id);
%>
<%
	//获取登录标记
	Object loggedFlag = request.getSession().getAttribute("loggedFlag");
%>
<c:if test="${loggedFlag == 1}">
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加博文</title>
    <link rel="stylesheet" href="/PersonalBlog/backManaSyst/css/articleAdd.css">
    
    <link rel="stylesheet" type="text/css" href="/PersonalBlog/backManaSyst/simditor/styles/simditor.css" >
    <script type="text/javascript" src="/PersonalBlog/backManaSyst/simditor/scripts/jquery.min.js"></script>
    <script type="text/javascript" src="/PersonalBlog/backManaSyst/simditor/scripts/module.js"></script>
    <script type="text/javascript" src="/PersonalBlog/backManaSyst/simditor/scripts/hotkeys.js"></script>
    <script type="text/javascript" src="/PersonalBlog/backManaSyst/simditor/scripts/uploader.js"></script>
    <script type="text/javascript" src="/PersonalBlog/backManaSyst/simditor/scripts/simditor.js"></script>
</head>
<body>
    <div class="editArti">
        <h1>编辑博文</h1>
        <form action="/PersonalBlog/artieditor" method="POST">
            <!-- 重写选文件按钮 -->
<!--             <div class="resetFile divSet"> -->
<!--                 <label for="fileUpload"><div><i class="iconfont iconshangchuanwenjian"></i>上传封面图</div></label> -->
<!--                 <input type="file" name="fileUpload" id="fileUpload"> -->
<!--             </div><br><br> -->
<!-- 			隐藏表单 -->
			<input type="hidden" name="id" value="<%=id%>"/>
            <div class="divSet"><span>标题：</span><input type="text" name="title" placeholder="请输入标题" value="<%=arti.getTitle()%>"> </div>
            <div class="divSet"><span>文章内容</span><textarea name="content" id="editor"><%=arti.getContent() %></textarea> </div>
            <div class="divSet"><span>文章描述</span><textarea name="discript" id="" cols="30" rows="10"><%=arti.getDecrip() %></textarea></div>
            
            <div class="resetSubmit">
                <label for="submit"><div>发布</div></label>
                <input type="submit" value="发布" name="submit" id="submit"> 
            </div>
            
           <div class="resetRe">
                <label for="reset"><div>重置</div></label>
                <input type="reset" name="reset" id="reset">
           </div>
        </form>
    </div>
    <script type="text/javascript">
        ( function(){
            Simditor.locale = 'zh-CN';
            let ed = new Simditor({
                textarea: $('#editor')
            });
        })();
    </script>
    <script src="/PersonalBlog/backManaSyst/js/articleAdd.js"></script>
</body>
</html>
</c:if>

<%
	if(loggedFlag == null || (int)loggedFlag == 0 || (int)loggedFlag == 3){
		request.getSession().setAttribute("loggedFlag", 3);	//表示从该页面跳转到登录页面，需要提醒用户登录后再操作该页面
		response.sendRedirect("/PersonalBlog/backManaSyst/login.jsp");
	}
%>